//
// Created by Semir on 2020/6/3.
//

#include <iostream>
#include <vector>

using namespace std;

int getMin(int a, int b, int c) {
    a = min(a, b);
    return min(a, c);
}

int GetUglyNumber_Solution(int index) {
    vector<int> arr(10000);
    for (int i = 0; i < 6; i++) {
        arr[i] = i;
    }
    if (index < 6) {
        return arr[index];
    }
    int i2 = 3;
    int i3 = 2;
    int i5 = 2;
    int i = 6;
    while (i <= index) {
        int minVal = getMin(arr[i2] * 2, arr[i3] * 3, arr[i5] * 5);
        arr[i] = minVal;
        while (arr[i2] * 2 <= minVal) {
            i2++;
        }
        while (arr[i3] * 3 <= minVal) {
            i3++;
        }
        while (arr[i5] * 5 <= minVal) {
            i5++;
        }
        i++;
    }
    return arr[index];
}

int main() {
    int res = GetUglyNumber_Solution(1500);
    cout << res << endl;
    return 0;
}